public class Uart
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MODULE_RS232 |
| Modifier and Type | Method and Description |
|---|---|
boolean |
close()
关闭串口
|
static Uart |
getInstance() |
boolean |
open(int module,
java.lang.String path,
int baudrate,
int databits,
int stopbits,
int check)
打开串口
|
boolean |
open(java.lang.String path,
int baudrate)
打开串口(databits:8 stopbits:1 check:0)
|
boolean |
open(java.lang.String path,
int baudrate,
int databits,
int stopbits,
int check)
打开串口
|
byte[] |
receive()
接收数据
|
boolean |
send(byte[] data)
发送数据
Send data. |
int |
sendAndReceive(byte[] sendData,
byte[] outData)
发送接收数据
|
public static final int MODULE_RS232
public static Uart getInstance()
public boolean open(java.lang.String path,
int baudrate)
path - 串口路径baudrate - 波特率public boolean open(java.lang.String path,
int baudrate,
int databits,
int stopbits,
int check)
path - 串口路径baudrate - 波特率databits - 数据位 取值为 7 或者8stopbits - 停止位 取值为 1 或者2check - 效验类型 取值为 0无, 1奇, 2偶public boolean open(int module,
java.lang.String path,
int baudrate,
int databits,
int stopbits,
int check)
module - 传递-1path - 串口路径baudrate - 波特率databits - 数据位 取值为 7 或者8stopbits - 停止位 取值为 1 或者2check - 效验类型 取值为 0无, 1奇, 2偶public boolean close()
public boolean send(byte[] data)
data - 数据 public byte[] receive()
public int sendAndReceive(byte[] sendData,
byte[] outData)